//
//  DMOrderDetailCell.m
//  DMGME
//
//  Created by ihope99 on 15/8/31.
//  Copyright (c) 2015年 GYP. All rights reserved.
//

#import "DMOrderDetailCell.h"
#import "DMoeferDetailModel.h"
#import "UIImageView+WebCache.h"
@implementation DMOrderDetailCell

- (void)awakeFromNib {
    // Initialization code
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
      UIImageView * headImageView = [[UIImageView alloc] init];
        headImageView.frame = CGRectMake(15, 9, 40, 50);
        headImageView.backgroundColor = [UIColor colorWithWhite:230/255.0 alpha:1];
        _headImageView = headImageView;
        [self.contentView addSubview:headImageView];
        
       UILabel *headLable = [[UILabel alloc] init];
        headLable.frame = CGRectMake(CGRectGetMaxX(_headImageView.frame)+15, 15, 150 ,13);
        headLable.backgroundColor = [UIColor clearColor];
        headLable.font = [UIFont systemFontOfSize:13];
        headLable.textColor = [UIColor grayColor];
        headLable.text = @"标题";
        _headLable = headLable;
        [self.contentView addSubview:headLable];
        
        
       UILabel *typeLable = [[UILabel alloc] init];
        typeLable.frame = CGRectMake(CGRectGetMaxX(_headImageView.frame)+15, CGRectGetMaxY(_headLable.frame)+10, 60 ,13);
        typeLable.backgroundColor = [UIColor clearColor];
        typeLable.font = [UIFont systemFontOfSize:13];
        typeLable.textColor = [UIColor grayColor];
        typeLable.text = @"好漫画";
        _typeLable = typeLable;
        [self.contentView addSubview:typeLable];
        
        UILabel *moneyLable = [[UILabel alloc] init];
        moneyLable.frame = CGRectMake(KWidth-70,20, 60,17);
        moneyLable.backgroundColor = [UIColor clearColor];
        moneyLable.font = [UIFont systemFontOfSize:13];
        moneyLable.textColor = [UIColor grayColor];
        moneyLable.textAlignment = NSTextAlignmentLeft;
        moneyLable.text = @"10.00";
        _moneyLable = moneyLable;
        [self.contentView addSubview:moneyLable];
        
        UILabel *numLable = [[UILabel alloc] init];
        numLable.frame = CGRectMake(_moneyLable.frame.origin.x+5,43, 40,10);
        numLable.backgroundColor = [UIColor clearColor];
        numLable.font = [UIFont systemFontOfSize:12];
        numLable.textColor = [UIColor grayColor];
        numLable.text = @"x10";
        numLable.textAlignment = NSTextAlignmentLeft;
        _numLable = numLable;
        [self.contentView addSubview:numLable];
        
    }
    return self;
}
-(void)setDModel:(DMoeferDetailModel *)dModel
{
    _dModel = dModel;
       if(dModel.cover.length == 0)
    {
        _headImageView.backgroundColor = [UIColor colorWithWhite:230/255.0 alpha:1];
    }
    else{
      _headImageView.backgroundColor = [UIColor colorWithWhite:230/255.0 alpha:1];  
    [_headImageView sd_setImageWithURL:[NSURL URLWithString:dModel.cover]];
        
    }
    if([dModel.period  isEqual: @""]||(dModel.period.intValue==0))
    {
        _headImageView.frame = CGRectMake(15, 9, 50, 50);
        _typeLable.hidden = YES;
    }
    else
    {
    _typeLable.text = [NSString stringWithFormat:@"%@期",dModel.period];
    }
    if (dModel.title == nil || dModel.title == NULL) {
        _headLable.text = [NSString stringWithFormat:@"加载...."];
    }else{
        _headLable.text = [NSString stringWithFormat:@"%@",dModel.title];

    }
        _numLable.text = [NSString stringWithFormat:@"x%d",dModel.num];
    _moneyLable.text = [NSString stringWithFormat:@"￥%@",dModel.retail_price];
   }
/*
 @property (nonatomic, strong) UILabel *headLable;
 @property (nonatomic, strong) UILabel *typeLable;
 @property (nonatomic, strong) UILabel *moneyLable;
 @property (nonatomic, strong) UILabel *numLable;
 @property (nonatomic, strong) UIImageView *headImageView
 */

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
